package org.Leetcode;

import java.util.HashSet;
import java.util.Set;

public class E05Leetcode136 {

    /*
        方法一：hashSet
     */
    public int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();

        for(int i = 0; i < nums.length; i++){
            int key = nums[i];
            if(!set.add(key)){
                set.remove(key);
            }
        }

        return set.toArray(new Integer[0])[0];
    }
}
